<template>
	<view class="content">
		<view class="form">
			<u-form  ref="uForm">
				<view>
					<u-form-item border="true" label="学生姓名:" label-width="140" >
						<u-input v-model="name"  placeholder="请输入姓名"/>
					</u-form-item>
					<u-form-item border="true" label="手机号码:" label-width="140">
						<u-input v-model="number" type="number" placeholder="请输入手机号码"/>
					</u-form-item>
					<u-form-item border="true" label="毕业学校:" label-width="140">
						<u-input v-model="school" placeholder="请输入毕业学校"/>
					</u-form-item>
					<u-form-item border="true" label="咨询专业:" label-width="140">
						<u-input v-model="major" placeholder="请输入要咨询的专业"/>
					</u-form-item>
					<u-form-item border="true" label="备 注:" label-width="140">
						<u-input v-model="extra" type="textarea" placeholder="非必填,备注信息"/>
					</u-form-item>
				</view>
				<u-button type="primary" style class="u-margin-top-40" @click="submit()">提交</u-button>
			</u-form>
		</view>
		<view class="footer">
			 Copyright 2021 临沂科技职业学院
		</view>
	</view>
</template>

<script>
	import request from "../../util/request.js"
	import api from "../../util/api.js"
	import check from "../../util/check.js"
	export default {
		data() {
			return {
				name:"",
				number:"",
				school:"",
				major:"",
				extra:""
			}
		},
		methods: {
			submit: function() {
				if (!this.name) {
					uni.showToast({
						icon: 'none',
						title: '姓名不能为空'
					})
				}
				if (!this.number) {
					uni.showToast({
						icon: 'none',
						title: '手机号码不能为空'
					})
				}
				if (!this.school) {
					uni.showToast({
						icon: 'none',
						title: '毕业学校不能为空'
					})
				}
				if (!this.major) {
					uni.showToast({
						icon: 'none',
						title: '咨询专业不能为空'
					})
				}
				request.post(api.studentAdd, {
					username: this.name,
					phone: this.number,
					school: this.school,
					major: this.major,
					extra: this.extra
				}).then(res => {
					// console.log(res);
					if (res.data.status == 1) {
						uni.showToast({
							icon: 'none',
							duration: 5000,
							title: '提交成功，近期请保持手机畅通，学校招办会给回访电话!'
						})
					} else {
						uni.showToast({
							icon: 'none',
							duration: 3000,
							title: res.data.msg
						})
					}
				}).catch(ex => {
					console.log(ex);
					uni.showToast({
						icon: 'none',
						title: '请求失败，请稍后再试'
					})
				})
			}
		}
	}
</script>

<style>
	.content {
		background-color: #f8f8f8;
		padding: 20rpx;
		min-height: 700px;
	}
	.form {
		background-color: #FFFFFF;
		padding: 20rpx;
	}
	.info_list_title {
		border-left: solid 10rpx #0095f0;
		padding: 0 10rpx;
		margin: 20rpx 0;
		font-size: 35rpx;
		font-weight: 500;
	}
	.footer {
		color: #000000;
		text-align: center;
		left: 0;
		right: 0;
		position: fixed;
		bottom: 15rpx;
		/* text-decoration: underline; */
		/* font-weight: 600; */
	}
</style>
